package com.turbo;

import com.turbo.boot.crawler.spider.TurboCrawler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 描述
 *
 * @author wuyn
 * @since 2024/4/17
 */
@Component
public class AppBoot implements CommandLineRunner {

    private static final Logger logger = LoggerFactory.getLogger(AppBoot.class);

    @Resource
    private Map<String, TurboCrawler> turboCrawlerMap;

    public void run(String... args) throws Exception {

        for (String key : turboCrawlerMap.keySet()) {
            try {
                turboCrawlerMap.get(key).crawl();
//                Thread.sleep(10000);
            } catch (Exception e) {
                logger.error("", e);
            }
        }
    }
}
